package com.heima.wemedia.controller;
// 爱情不是随便许诺,算了,不想再说了

import com.heima.common.dtos.PageResult;
import com.heima.model.admin.dtos.SensitiveDto;
import com.heima.wemedia.entity.WmSensitive;
import com.heima.wemedia.service.WmSensitiveService;
import com.heima.wemedia.service.WmUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
public class WmSensitiveController {

    @Autowired
    private WmSensitiveService sensitiveService;


    /**
     * 敏感词列表查询
     *
     * @param dto
     * @return
     */
    @PostMapping("/api/v1/sensitive/list")
    PageResult<SensitiveDto> findByPage(@RequestBody SensitiveDto dto) {

        PageResult<SensitiveDto> byPage1 = sensitiveService.findByPage(dto);

        return byPage1;
    }


    /**
     * 添加敏感词
     *
     * @param sensitiveDto
     * @return
     */
    @PostMapping("/api/v1/sensitive/save")
    boolean saveSensitive(@RequestBody SensitiveDto sensitiveDto) {
        boolean b = sensitiveService.saveSensitive(sensitiveDto);

        return b;
    }

    /**
     * 修改敏感词
     *
     * @param dto
     * @return
     */
    @PutMapping("/api/v1/sensitive/update")
    boolean updateById(@RequestBody SensitiveDto dto) {


        boolean b = sensitiveService.updateByIdSensitive(dto);

        return b;
    }

    /**
     * 删除敏感词
     * @param
     * @return
     */
    @DeleteMapping("/api/v1/sensitive/del/{id}")
    boolean deleteById(@PathVariable("id") Integer id){
       boolean b = sensitiveService.deleteById(id);
        return b;
    }
}
